import Vue from 'vue'
import VueRouter from "vue-router";

import ExpandRows from '@/components/vxetable/ExpandRows.vue';
import ShowData from '@/components/vxetable/ShowData.vue';
import ShowDataBF from '@/components/vxetable/ShowDateBF.vue';
import MachineLine from '@/components/echarts/MachineLine.vue';
import MachinePie from '@/components/echarts/MachinePie.vue';
// import UploadFile from '@/components/upload/UploadFile';
import AddOrders from '@/components/upload/AddExternalOrders';

Vue.use(VueRouter)


const routes  = [
    // 中控数据看板
    {
        name: 'showdatabf',
        path: '/showdatabf',
        component: ShowDataBF
    },
    // 中控数据看板
    {
        name: 'showdata',
        path: '/showdata',
        component: ShowData
    },
    // 损耗监控看板
    {
        name: 'expandrows',
        path: '/expandrows',
        component: ExpandRows
    },
    // 折线图
    {
        name: 'machineline',
        path: '/machineline',
        component: MachineLine
    },
    {
        name: 'machinepie',
        path: '/machinepie',
        component: MachinePie
    },
    // {
    //     name: 'uploadfile',
    //     path: '/uploadfile',
    //     component: UploadFile
    // },
    {
        name: 'addorders',
        path: '/addorders',
        component: AddOrders
    }




]   //route对象（填写路由）


// 创建 router 实例
const router = new VueRouter({
    mode: 'hash', // 设置为 hash 模式
    routes // 等价于 routes: routes
})
router.beforeEach((to, from, next) => {
    // 在路由跳转前设置页面标题
    if (to.matched.length > 0) {
        // 假设每个路由元信息中都有一个 title 字段
        const title = to.matched[0].meta.title || '默认标题';
        document.title = title;
    }
    // 确保一定要调用 next() 方法来 resolve 这个钩子
    // 否则路由不会变化
    next();
});
export default router;
